﻿// Project: Salient
// http://salient.codeplex.com
// 
// Copyright 2010, Sky Sanders <sky at skysanders.net>
// Dual licensed under the MIT or GPL Version 2 licenses.
// http://salient.codeplex.com/license
// 
// Date: April 24 2010 

#region

using System;
using System.Collections.Specialized;
using System.Reflection;
using Salient.SqlServer.Management;

#endregion

namespace Salient.SqlServer.Testing
{
    ///<summary>
    ///</summary>
    public abstract class DatabaseFixture : Database
    {
        

  

        private readonly StringCollection _scripts = new StringCollection();
        private int _uuid;


        /// <summary>
        /// 
        /// </summary>
        /// <param name="dataSource"></param>
        /// <param name="initialCatalog"></param>
        protected DatabaseFixture(string dataSource, string initialCatalog)
            : base(dataSource, initialCatalog)
        {
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="dataSource"></param>
        /// <param name="initialCatalog"></param>
        /// <param name="userId"></param>
        /// <param name="password"></param>
        protected DatabaseFixture(string dataSource, string initialCatalog, string userId, string password)
            : base(dataSource, initialCatalog, userId, password)
        {
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="connectionString"></param>
        protected DatabaseFixture(string connectionString)
            : base(connectionString)
        {
        }

        /// <summary>
        /// 
        /// </summary>
        protected StringCollection Scripts
        {
            get { return _scripts; }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        protected int NextId()
        {
            return ++_uuid;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        protected static int TI()
        {
            return Environment.TickCount;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        protected static decimal TD()
        {
            return Environment.TickCount;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        protected static string TS()
        {
            return Environment.TickCount.ToString();
        }

        ///<summary>
        ///</summary>
        public virtual void TestFixtureSetUp()
        {
            DropAndCreate(_scripts);
        }


        ///<summary>
        ///</summary>
        public virtual void TestFixtureTearDown()
        {
            Drop();
        }
    }
}